#include <iostream>
#include <string>
#include <memory>
#include <jsoncpp/json/json.h>

int main()
{
  std::string str = R"({"姓名":"小明","年龄":18,"成绩":[76.5,55,88] })";
  
  Json::Value root;

  Json::CharReaderBuilder crb;
  std::unique_ptr<Json::CharReader> cr(crb.newCharReader());

  std::string err;

  bool parsingSuccessful = cr->parse(
      str.c_str(),
      str.c_str()+str.size(),
      &root,
      &err
      );
  if(!parsingSuccessful){
      std::cerr << "JSON解析失败:" << err <<std::endl;
      return 1;
  }

  std::cout<< root["姓名"].asString()<<std::endl;
  std::cout<<root["年龄"].asInt()<<std::endl;
  
  int sz = root["成绩"].size();
  for(int i=0;i<sz;i++){
    std::cout << root["成绩"][i].asFloat()<< std::endl;
  }

  return 0;
}
